﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:odc="http://opendope.org/conditions" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://opendope.org/conditions" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="conditions">
    <xs:complexType>
      <xs:sequence> <!-- must use Array rather than List in Xsd2Code; but didn't have to for xpaths? -->
        <xs:element maxOccurs="unbounded" ref="odc:condition" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="condition">
    <xs:complexType>
      <xs:sequence> 
        <xs:choice  maxOccurs="1">
          <xs:element minOccurs="0" ref="odc:xpathref" />
          <xs:element minOccurs="0" ref="odc:and" />
          <xs:element minOccurs="0" ref="odc:or"  />
          <xs:element minOccurs="0" ref="odc:not"  />
        </xs:choice>
      </xs:sequence>
      <xs:attribute name="id" type="xs:ID" use="required" />
      <xs:attribute name="name" type="xs:string" />
      <xs:attribute name="descrption" type="xs:string" />
      <xs:attribute name="comments" type="xs:string" />
    </xs:complexType>
  </xs:element>

  <xs:element name="true"/>
  <xs:element name="false"/>

  <xs:element name="and">
    <xs:complexType>
      <xs:sequence>
        <xs:choice maxOccurs="unbounded">
          <xs:element minOccurs="0" ref="odc:xpathref" />
          <xs:element minOccurs="0" ref="odc:and" />
          <xs:element minOccurs="0" ref="odc:or"  />
          <xs:element minOccurs="0" ref="odc:not"  />
          <xs:element minOccurs="0" ref="odc:conditionref"  />
          <xs:element minOccurs="0" ref="odc:true" />
          <xs:element minOccurs="0" ref="odc:false"  />
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="or">
    <xs:complexType>
      <xs:sequence>
      <xs:choice maxOccurs="unbounded">
        <xs:element minOccurs="0" ref="odc:xpathref" />
        <xs:element minOccurs="0" ref="odc:and" />
        <xs:element minOccurs="0" ref="odc:or"  />
        <xs:element minOccurs="0" ref="odc:not"  />
        <xs:element minOccurs="0" ref="odc:conditionref"  />
        <xs:element minOccurs="0" ref="odc:true" />
        <xs:element minOccurs="0" ref="odc:false"  />
      </xs:choice>
    </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="not">
    <xs:complexType>
      <xs:sequence>
        <xs:choice maxOccurs="1">
          <xs:element minOccurs="0" ref="odc:xpathref" />
          <xs:element minOccurs="0" ref="odc:and"  />
          <xs:element minOccurs="0" ref="odc:or"  />
          <xs:element minOccurs="0" ref="odc:not"  />
          <xs:element minOccurs="0" ref="odc:conditionref"  />
          <xs:element minOccurs="0" ref="odc:true" />
          <xs:element minOccurs="0" ref="odc:false"  />
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="xpathref">
    <xs:complexType>
      <xs:attribute name="id" type="xs:NCName" use="required" />
    </xs:complexType>
  </xs:element>

  <xs:element name="conditionref">
    <xs:complexType>
      <xs:attribute name="id" type="xs:NCName" use="required" />
    </xs:complexType>
  </xs:element>

        </xs:schema>